from comm.seafile_func import seafile_query_repo

host = 'http://192.168.116.128:38000/'
path_login_1 = 'api2/auth-token/'
path_info_2 = 'api2/account/info/'
path_add_query_repo_3_4 = 'api2/repos/'
path_modify_repo = 'api2/repos/1.4查询到的repoid/?op=rename'
path_del_repo = 'api2/repos/id(1.4接口里查到的资料库id值)/'
path_add_del_file = 'api2/repos/资料库id/file/?p=/aaa&reloaddir=true'


def get_path_5_6_7_8(repo_name, x, file_name=None):
    if x == 5:
        target_id = None
        for repo in seafile_query_repo().json():
            if repo['name'] == repo_name:
                target_id = repo['id']
            path_modify_repo = f'api2/repos/{target_id}/?op=rename'
            return path_modify_repo
    elif x == 6:
        target_id = None
        for repo in seafile_query_repo().json():
            if repo['name'] == repo_name:
                target_id = repo['id']
        path_del_repo = f'api2/repos/{target_id}'
        return path_del_repo
    elif x == 7 or x == 8:
        target_id = None
        for repo in seafile_query_repo().json():
            if repo['name'] == repo_name:
                target_id = repo['id']
        path_add_del_file = f'api2/repos/{target_id}/file/?p=/{file_name}&reloaddir=true'
        return path_add_del_file

path5 = get_path_5_6_7_8('坤坤判刑群',5)
url5 = host+path5
print('1.5的地址是：',url5)

path6 = get_path_5_6_7_8('坤坤判刑群',6)
url6 = host+path6
print('1.6的地址是：',url6)

path7 = get_path_5_6_7_8('坤坤判刑群',7,'吊毛周露')
url7 = host+path7
print('1.7的地址是：',url7)


